package org.com.db.util;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {

	final static int DB_VISON = 2;
	final static String DATABASE_NAME = "DB01";

	public DBHelper(Context context) {
		super(context, DATABASE_NAME, null, DB_VISON);

	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE Produce (objectId TEXT, price TEXT, pic TEXT, describe TEXT, name TEXT);");
		db.execSQL("CREATE INDEX objectId ON Produce(objectId ASC);");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		onDropTable(db);
		onCreate(db);
	}

	public void onDropTable(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS Produce;");

	}

}
